//
//  ModelCell.m
//  Demo
//
//  Created by lx on 2018/12/25.
//  Copyright © 2018 mgz. All rights reserved.
//

#import "ModelCell.h"
#import <Masonry.h>
@implementation ModelCell
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.titleLab =[[UILabel alloc]init];
        [self.contentView addSubview:self.titleLab];
        self.titleLab.backgroundColor = [UIColor redColor];
        self.titleLab.textColor = [UIColor whiteColor];
        self.titleLab.font = [UIFont boldSystemFontOfSize:15];
        self.titleLab.textAlignment = NSTextAlignmentLeft;
        [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.mas_equalTo(self.contentView).mas_offset(30);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-30);
            make.height.mas_offset(20);
        }];
        
        self.img = [[UIImageView alloc]init];
        [self.contentView addSubview:self.img];
        [self.img mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.titleLab.mas_bottom).mas_offset(0);
            make.left.and.right.mas_equalTo(self.contentView);
            make.height.mas_offset(20);
        }];
    }
    return self;
}
- (void)setModel:(Model *)model{
    self.titleLab.text = [NSString stringWithFormat:@"这是Model的cell|||%@",model.str];
    if (model.number.integerValue == 2222) {
        self.img.backgroundColor = [UIColor yellowColor];
    }else{
        self.img.backgroundColor = [UIColor lightGrayColor];
    }
}

@end
